<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    
    <title>考勤 - 请假管理</title>

	
	<link href="<%=basePath %>/background/css/layout.css" rel="stylesheet" type="text/css" />
    <link href="<%=basePath %>/background/css/header.css" rel="stylesheet" type="text/css" />
	
  	<script src="<%=basePath %>/jquery/jquery-1.4.2.js"></script>
  	
  	<script src="<%=basePath %>/jquery/ui/jquery.ui.core.js"></script>
	<script src="<%=basePath %>/jquery/ui/jquery.ui.widget.js"></script>
	 <script>
   
    
	
	</script>
  </head>
  
  <body>
  
  <table  width="100%"  border="0" cellpadding="0" cellspacing="0" height="100%">
  	<tr valign="top">
  	
  		<td height="100">
  			 <jsp:include page="/background/head.jsp"></jsp:include>
  		</td>
  	</tr>
  	<tr valign="top">
  		<td>
  		
   
   
  <table width="100%"  border="0" cellpadding="0" cellspacing="0">
  
 <tr>
    	<td width="270" align="center">
    		
    	</td>
    	<td width="100%">

    	</td>
    </tr>
    
    <tr>
    	<td valign="top">
     		<div>
     		
     		</div>
					<s:include value="/background/left.jsp"></s:include>		
     	</td>
     	
     	
     	<td valign="top" >
     	
     	<table width="100%" border="0" cellpadding="0" bgcolor="#e5f3ff" cellspacing="0" style= "border:1px solid #ffffff; border-top-color:#6cb1f1;">
     		<tr>
     			<td>考勤 - 请假管理
     			
     			<input type="button" value="查看谁有权限" 
     				onclick="javascript:openUrlForDialog('selectoperatorlimitedAction_background.action?limitedCode=<s:property value="limitedcode"/>')"/>
     			</td>
     			<td align="right">
     			
     			<a href="/attendance/cecalculator/">考勤计算器</a>  
     			<a href="preaddleave_attendance.action">申请请假</a> 
     			</td>
     		</tr>
     	</table>
     	
     	<table align="center">
     		<tr>
     			<td><s:fielderror id="errormessage" /></td>
     		</tr>
     	</table>
     	
    <form id="" name="" onSubmit="return true;" action="manageleave_attendance.action" method="POST" >
    	
			<table  border="0" >
				<tr>
				  <td align="right" width="150">
					
				  </td>
				  <td>
					 
				  </td>
			  </tr>

			</table>
	</form> 
	
	<table width="100%" border="0" cellpadding="0" bgcolor="#e5f3ff" cellspacing="0" style= "border:1px solid #ffffff; border-top-color:#6cb1f1;">
     		<tr>
     			<td>我的请假记录
     			</td>
     			<td align="right">
     			
     			 </td>
     		</tr>
     	</table>
			<table >
			
		
			<s:iterator value="leaveList" id="leaveList">
				<tr>

					<td>
						

<table border="0" cellpadding="0"  cellspacing="0" width="100%"    style= "border:1px solid #ffffff; border-bottom-color:#b2d5ff;
    border-left-color:#b2d5ff;border-right-color:#b2d5ff;border-top-color:#b2d5ff">
									<tr>
										<td>
											<table bgcolor="#f3f7fc" width="100%" >
												<tr>
													<td>
													<s:if test="#leaveList.iscancel_leave == true">
													<s>
														请假号:
														<a href="infoleave_attendance.action?id=<s:property value="#leaveList.id_leave"/>"><s:property value="#leaveList.id_leave"/></a>
														</s>
													</s:if>
													<s:else>
														请假号:
														<a href="infoleave_attendance.action?id=<s:property value="#leaveList.id_leave"/>"><s:property value="#leaveList.id_leave"/></a>
													</s:else>
														部门:<s:property value="#leaveList.departmentname_leave"/>
														
													</td>
													
												 	<td align="right">
														申请时间:<s:property value="#leaveList.createdate_leave"/>
													</td>
													
												</tr>
											</table> 
											
										</td>
									</tr>
									<tr>
										<td>
											<table width="100%" border="1" cellpadding="0"  cellspacing="0" bordercolor="#f5f5f5" style="border-collapse:collapse; border-width:1px 0 0 1px;">
												<tr>
													<td width="105" align="center" title="<s:property value="#list.basicpay_operator"/>">
														
																	<s:property value="#leaveList.name_leave"/>
																	
													</td>
												
													<td width="235" height="55" align="center">
													
													<p><s:property value="#leaveList.date_leave"/>
													</p>
													
													<p><s:property value="#leaveList.begin_leave"/>
													~
													<s:property value="#leaveList.end_leave"/>
													</p>
													</td>
													
													<td width="200" height="55" align="center">
														<s:property value="#leaveList.reason_leave"/>
													</td>
													
													
													
													
													
													<td align="center" width="185">
														
														<s:if test="#leaveList.isapp_leave == true">
															
															<s:property value="#leaveList.appdate_leave"/>
														</s:if>
														<s:else>
															<a href="appleave_attendance.action?id=<s:property value="#leaveList.id_leave"/>">批准请假</a>
														</s:else>
													</td>
													
													<td align="center" width="105">
														
														<s:if test="#leaveList.isapp_leave == true">
															批准人:<s:property value="#leaveList.appname_leave"/>
														</s:if>
														<s:else>
															未批准
														</s:else>
													</td>
													
													<td align="center" >
														<a href="javascript:del('<s:property value="#leaveList.name_leave"/>',<s:property value="#leaveList.id_leave"/>);"> 取消</a>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									
									
									
							</table>
					
					
					
						
					</td>	
				
				</tr>
				
				</s:iterator>	
		</table>
		
		<table width="100%" border="0" cellpadding="0" bgcolor="" cellspacing="0" >
				<tr >
					<td >
						<%
						
						
						
						String url = "attendance/manageleave_attendance.action";//*/
						int pageSize = (Integer) request.getAttribute("pageSize");
						int beginPageNum =  (Integer) request.getAttribute("beginPageNum");
						int countRow =  (Integer) request.getAttribute("rowNum");
					    int countPage =(countRow-1)/pageSize+1;
					    int currentPage = countPage - (countRow-beginPageNum)/pageSize;
					    
					    
					    
					 	 
					    
					    String searchstr = (String)request.getParameter("searchStr");//*/
					    if(searchstr != null){
					    	searchstr = java.net.URLDecoder.decode(searchstr, "UTF-8");
					    	searchstr = java.net.URLEncoder.encode(searchstr,"UTF-8");
					    	searchstr = searchstr.replaceAll("%", "%25");
					    }else{
					    	searchstr = "";
					    }
					    
					    if((beginPageNum-pageSize+1) >= 1){%>
				    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum-pageSize) %>">
								上一页 </a>
				   <% }
					    
					    //beginPageNum =  (pageNum - 1) * pageSize;
						StringBuffer chagePageBuff = new StringBuffer();
						if(countPage >= 2){ 
							int begin = currentPage - 9;
							int end = currentPage + 9;
							
							if(begin < 1){
								begin = 0;
							}
							if(end > countPage){
								end = countPage-1;
							}
							
							
							for(int i=begin;i<countPage;i++){
								
								
								
								
								
								if(beginPageNum == i*pageSize){
									%>
									<%=i+1 %>
									<%
								}else{
									%>
									<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=i*pageSize %>">
									[<%=i+1 %>] </a>
									<%
								}
								
								if(i > end){
									
									break;
									
								}
							}
						}
						
						if((beginPageNum+pageSize-countRow) < 0){%>
				    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum+pageSize) %>">
								下一页 </a>
				   		<% }
						if(countPage != 1){%>
			    		<input type="text" size="4" id="goPageNum" name="goPageNum"/> / <%=countPage %> <button onclick="gotoPage();">跳转</button>
				   		<% }
						//*/
						%>
					</td>

				</tr>
				
			</table>
	
			
	</td>

	
</tr>


</table>

</td>
</tr>
<tr valign="bottom">
	<td>
		<jsp:include page="/background/tail.jsp"></jsp:include>
	</td>
</tr>
</table>


  </body>
  
  <script type="text/javascript">
  
  function del(name,id){
		if(confirm("删除 "+" 请假单号:"+id+" \"" + name + "\" ")){
			window.location.href='cancelleave_attendance.action?id=' + id;
		}
	}
  function gotoPage(){
		countPage = <%=countPage %>;
		pageSize = <%=pageSize %>;
		pageNum = document.getElementById("goPageNum").value;

		pageNum = parseInt(pageNum);
		if(pageNum > countPage){
			pageNum = countPage;
		}
		beginPageNum = pageNum * pageSize - pageSize;
		if(beginPageNum < 0){
			beginPageNum = 0;

		}
		if(isNaN(beginPageNum)){ 
			beginPageNum = 0;
		}
		url = '<%=url %>?searchStr=<%=searchstr %>&beginPageNum=' + beginPageNum;
		//alert(url);
		window.location.href=url;
	}

	
  </script>

</html>
